package com.centriole.service.workflow.common;

import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;

public class QueryVo {

    /* 用户id*/
    private String userId;

    /* 流程实例id*/
    private String instaceId;

    /*  执行人姓名 */
    private String executorName;

    /*  应用名(比如: service-log , service-mainData)*/
    private String appName;

    /* 流程定义key，用来区别一个"流程定义"，流程定义是 工作流的概念，详情参考百度*/
    private String processDefinitionKey;

    /* 流程实例的状态: 进行中、已结束*/
    private String state;

    /* 流程实例的发起人名字【不是发起人id!】*/
    private String applyUser;

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    private Date startTime;

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    private Date finishTime;

    /* 一段时间(单位: 天 )还没有结束的流程实例，就被称为 “死流程”*/
    private Integer deadTime;          //一般是7天，15天，30天

    /* 分页 */
    private Integer limit;
    private Integer page;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getInstaceId() {
        return instaceId;
    }

    public void setInstaceId(String instaceId) {
        this.instaceId = instaceId;
    }

    public String getExecutorName() {
        return executorName;
    }

    public void setExecutorName(String executorName) {
        this.executorName = executorName;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getProcessDefinitionKey() {
        return processDefinitionKey;
    }

    public void setProcessDefinitionKey(String processDefinitionKey) {
        this.processDefinitionKey = processDefinitionKey;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Integer getDeadTime() {
        return deadTime;
    }

    public void setDeadTime(Integer deadTime) {
        this.deadTime = deadTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public String getApplyUser() {
        return applyUser;
    }

    public void setApplyUser(String applyUser) {
        this.applyUser = applyUser;
    }

    public String convertState(){
        if(StringUtils.isBlank(state)) return "-1";
        switch (state){
            case "1":
                return "0";         // 在com.centriole.service.workflow.service.ActManagerService.findApplyInstaces 里 “0”表示运行中
            case "2":
                return "1";       // 在com.centriole.service.workflow.service.ActManagerService.findApplyInstaces 里 “1”表示以结束
                default:    return "-1";
        }
    }

    public QueryVo() {
    }

    public QueryVo(Integer deadTime) {
        this.deadTime = deadTime;
    }

    @Override
    public String toString() {
        return "QueryVo{" +
                "userId='" + userId + '\'' +
                ", instaceId='" + instaceId + '\'' +
                ", appName='" + appName + '\'' +
                ", processDefinitionKey='" + processDefinitionKey + '\'' +
                ", state='" + state + '\'' +
                ", startTime=" + startTime +
                ", finishTime=" + finishTime +
                ", deadTime=" + deadTime +
                ", limit=" + limit +
                ", page=" + page +
                '}';
    }
}
